<?php

/*
 * Convert Helper Create by Idin 2012/08/29
 */
     function convertUTF8($str) {
         
        if (is_object($str)) {
            $ouput = array();
            foreach ($str as $row => $key) {
                $ouput[$row] = convertUTF8($key);
            }
            return (object) $ouput;
        } else if (is_array($str)) {
            $ouput = array();
            foreach ($str as $row => $key) {
                $ouput[$row] = convertUTF8($key);
            }
            return $ouput;
        } else {
            return iconv("utf-8","tis-620", $str);
        }
     
        
        
    }

     function convertTIS620($str) {
        if (is_object($str)) {
            $ouput = array();
            foreach ($str as $row => $key) {
                $ouput[$row] = convertTIS620($key);
            }
            return (object) $ouput;
        } else if (is_array($str)) {
            $ouput = array();
            foreach ($str as $row => $key) {
                $ouput[$row] = convertTIS620($key);
            }
            return $ouput;
        } else {
            return iconv('TIS-620', 'UTF-8', $str);
        }
    }

?>
